﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Web.Mvc;

namespace Bzure.Mvc.Html
{
    public class EntityPage<T>
    {
        List<T> list = new List<T>();
        public EntityPage()
        {
            this.FirstButton = MvcHtmlString.Create("<a href=\"#pager\">首页</a>");
            this.PreButton = MvcHtmlString.Create("<a href=\"#pager\">上一页</a>");
            this.NextButton = MvcHtmlString.Create("<a href=\"#pager\">下一页</a>");
            this.LastButton = MvcHtmlString.Create("<a href=\"#pager\">末页</a>");
            this.PageIndexLabelBefore = MvcHtmlString.Create("当前");
            this.PageIndexLabelAfter = MvcHtmlString.Create("页");
            this.RecordCountLabelBefor = MvcHtmlString.Create("共");
            this.RecordCountLabelAfter = MvcHtmlString.Create("条记录");
        }
        public T[] Entitys
        {
            get
            {
                return list.ToArray();
            }
        }
        public void AddEntity(T entity)
        {
            list.Add(entity);
        }
        public void AddRange(IEnumerable<T> collection)
        {
            list.AddRange(collection);
        }
        /// <summary>
        /// 第一页按钮
        /// </summary>
        public MvcHtmlString FirstButton { get; set; }
        /// <summary>
        /// 上一页按钮
        /// </summary>
        public MvcHtmlString PreButton { get; set; }
        /// <summary>
        /// 下一页按钮
        /// </summary>
        public MvcHtmlString NextButton { get; set; }
        /// <summary>
        /// 最后一页按钮
        /// </summary>
        public MvcHtmlString LastButton { get; set; }
        /// <summary>
        /// 页标示前文字
        /// </summary>
        public MvcHtmlString PageIndexLabelBefore { get; set; }
        /// <summary>
        /// 页标示后文字
        /// </summary>
        public MvcHtmlString PageIndexLabelAfter { get; set; }
        /// <summary>
        /// 记录数标示前文字
        /// </summary>
        public MvcHtmlString RecordCountLabelBefor { get; set; }
        /// <summary>
        /// 记录数标示后文字
        /// </summary>
        public MvcHtmlString RecordCountLabelAfter { get; set; }
        /// <summary>
        /// 页记录数
        /// </summary>
        public int PageSize { get; set; }
        /// <summary>
        /// 页码
        /// </summary>
        public int PageIndex { get; set; }
        /// <summary>
        /// 总页数
        /// </summary>
        public long PageCount { get; set; }
        /// <summary>
        /// 总记录数
        /// </summary>
        public long RecordCount { get; set; }
    }
}
